package cn.com.css.taxInspection.zzgl.controller;

import cn.com.css.taxInspection.attention.entity.CljamxEntity;
import cn.com.css.taxInspection.attention.entity.QtjamxEntity;
import cn.com.css.taxInspection.attention.service.CljamxService;
import cn.com.css.taxInspection.attention.service.QtjamxService;
import cn.com.css.taxInspection.common.aop.annotation.LogAnnotation;
import cn.com.css.taxInspection.common.result.DataResult;
import cn.com.css.taxInspection.common.result.Result;
import cn.com.css.taxInspection.gt3.entity.DmGySwjgEntity;
import cn.com.css.taxInspection.zdgz.entity.JaglYljamxEntity;
import cn.com.css.taxInspection.zdgz.service.JaglYljamxService;
import cn.com.css.taxInspection.zzgl.entity.YhglEntity;
import cn.com.css.taxInspection.zzgl.mapper.YhglMapper;
import cn.com.css.taxInspection.zzgl.service.YhglService;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 组织管理-用户管理
 */
@RequestMapping("/yhgl")
@RestController
@Api(tags = "用户管理")
public class YhglController {

    private static final Logger log = LoggerFactory.getLogger(YhglController.class);

    @Resource
    private YhglService yhglService;

    @PostMapping("/queryYhglData")
    @ApiOperation(value = "查询用户管理")
    @LogAnnotation(title = "查询", action = "查询用户管理")
    public DataResult queryYhglData(@RequestBody YhglEntity yhglEntity) throws ParseException {
        IPage<YhglEntity> iPage = yhglService.queryYhglData(yhglEntity);
        return DataResult.success(iPage);
    }

    @PostMapping("/queryYhglDataBySwryDm/{swryDm}")
    @ApiOperation(value = "根据税务人员代码查询用户")
    @LogAnnotation(title = "查询", action = "查询用户管理")
    public DataResult queryYhglDataBySwryDm(@PathVariable("swryDm") String swryDm) throws ParseException {
        YhglEntity yhglEntity = yhglService.queryYhglDataBySwryDm(swryDm);
        return DataResult.success(yhglEntity);
    }

    @PostMapping("/queryYhglDataBySwrysfDm/{swrysfDm}")
    @ApiOperation(value = "根据税务人员代码查询用户")
    @LogAnnotation(title = "查询", action = "查询用户管理")
    public DataResult queryYhglDataBySwrysfDm(@PathVariable("swrysfDm") String swrysfDm) throws ParseException {
        YhglEntity yhglEntity = yhglService.queryYhglDataBySwrysfDm(swrysfDm);
        return DataResult.success(yhglEntity);
    }

    @PostMapping("/delDataBySwryDm/{swrysfDm}")
    @ApiOperation(value = "根据税务人员代码删除用户")
    @LogAnnotation(title = "删除", action = "删除用户管理")
    public DataResult delDataBySwryDm(@PathVariable("swrysfDm") String swrysfDm) throws ParseException {
        int result = yhglService.delDataBySwryDm(swrysfDm);
        return DataResult.success(result);
    }

    @PostMapping("/queryYhglDataBySwjgDm/{swjgDm}")
    @ApiOperation(value = "根据税务机关代码查询用户")
    @LogAnnotation(title = "查询", action = "查询用户管理")
    public DataResult queryYhglDataBySwjgDm(@PathVariable("swjgDm") String swjgDm) throws ParseException {
        List<YhglEntity> yhglEntityList = yhglService.queryYhglDataBySwjgDm(swjgDm);
        return DataResult.success(yhglEntityList);
    }

    @PostMapping("/updataYhglData")
    @ApiOperation(value = "根据税务机关代码查询用户")
    @LogAnnotation(title = "查询", action = "查询用户管理")
    public DataResult updataYhglData(@RequestBody YhglEntity yhglEntity) throws ParseException {
        int result = yhglService.updataYhglData(yhglEntity);
        return DataResult.success(result);
    }

    @PostMapping("/saveYhglData")
    @ApiOperation(value = "根据税务机关代码查询用户")
    @LogAnnotation(title = "查询", action = "查询用户管理")
    public DataResult saveYhglData(@RequestBody YhglEntity yhglEntity) throws ParseException {
        int result = yhglService.saveYhglData(yhglEntity);
        return DataResult.success(result);
    }

}